package de.mmis.core.pojop.request;

import java.net.URI;

import de.mmis.core.pojop.answer.HTTPAnswer;

public class HTTPRequest implements Request {
	
	public enum RequestType
	{
		Echo,
		Error,
		URI,
	}
	
	private final RequestType type;
	
	// used by Echo type
	private byte[] echoData;
	private String echoContentType;
	
	// used by Error type
	private Exception exception;
	
	// used by URI type
	private URI uri;
	
	private HTTPRequest(RequestType type) {
		this.type = type;
	}
	
	public HTTPRequest(Exception exception)
	{
		this(RequestType.Error);
		this.exception = exception;
	}
	
	public HTTPRequest(byte[] echoData) {
		this(echoData,HTTPAnswer.DEFAULT_CONTENT_TYPE);
	}
	
	public HTTPRequest(byte[] echoData, String echoContentType) {
		this(RequestType.Echo);
		this.echoData = echoData;
		this.echoContentType = echoContentType;
	}
	
	public HTTPRequest(URI uri) {
		this(RequestType.URI);
		this.uri = uri;
	}

	public RequestType getType() {
		return this.type;
	}

	public byte[] getEchoData() {
		return this.echoData;
	}

	public String getEchoContentType() {
		return this.echoContentType;
	}

	public Exception getException() {
		return this.exception;
	}

	public URI getURI() {
		return this.uri;
	}
}
